import os
import json
import copy
import random
import threading
import time

def get_fp():
    """
    随机指纹
    """
    import time
    import random
    e = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    t = len(e)
    milliseconds = int(round(time.time() * 1000))
    base36 = ''
    while milliseconds > 0:
        remainder = milliseconds % 36
        if remainder < 10:
            base36 = str(remainder) + base36
        else:
            base36 = chr(ord('a') + remainder - 10) + base36
        milliseconds = int(milliseconds / 36)
    r = base36
    o = [''] * 36
    o[8] = o[13] = o[18] = o[23] = '_'
    o[14] = '4'

    for i in range(36):
        if not o[i]:
            n = 0 or int(random.random() * t)
            if i == 19:
                n = 3 & n | 8
            o[i] = e[n]
    ret = "verify_" + r + "_" + ''.join(o)
    return ret


import requests

headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cache-Control": "no-cache",
    "Connection": "keep-alive",
    "Content-Type": "application/x-www-form-urlencoded",
    "Origin": "https://haohuo.jinritemai.com",
    "Pragma": "no-cache",
    "Referer": "https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?id=3634653387691285185&ins_activity_param=id5J6q7J&origin_type=pc_buyin_group&pick_source=v.bw0o7",
}

cookies = {
    "sessionid": 'bf63e135f19a3033f89082d2cc55fdb8',  # jl-cookie
}

url = "http://ecom5-normal-hl.ecombdapi.com/aweme/v2/shop/promotion/pack/h5/"

params = {
    "is_h5": "1",
    "is_native_h5": "1",
    "verifyFp": get_fp(),
    "origin_type": "pc_buyin_group",
    "msToken": "",
    "a_bogus": "",
}
data = {
    "ui_params": "{\"from_live\":false,\"from_video\":null,\"three_d_log_data\":null,\"follow_status\":null,\"which_account\":null,\"ad_log_extra\":null,\"from_group_id\":null,\"bolt_param\":null,\"transition_tracker_data\":null,\"selected_ids\":null,\"window_reposition\":null,\"is_short_screen\":null,\"full_mode\":true}",
    "use_new_price": "1",
    "is_h5": "1",
    "bff_type": "2",
    "is_in_app": "0",
    "promotion_ids": '3634653387691285185',
    "meta_param": "",
    "source_page": "",
    "request_additions": "",
    "isFromVideo": "false",
    "enable_timing": "true"
}
cnt = 0
proxies = {
    # "http": "http://JB3MYUjN:Nymx67mK@110.42.9.74:10035",
    # "https": "http://JB3MYUjN:Nymx67mK@110.42.9.74:10035"
}
while True:
    resp = requests.post(url, headers=headers, cookies=cookies, params=params, data=data,proxies=proxies)
    print(
        resp.text
    )
    time.sleep(1)
    print('cnt:', cnt)
    cnt += 1

    # 23:41